package 
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.system.ApplicationDomain;
	import flash.text.Font;
	import flash.display.Loader;
	import flash.net.URLRequest;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	/**
	 * ...
	 * @author Lorenzo Nuvoletta
	 */
	public class Main extends Sprite 
	{
		
		private var fontloader:Loader;
		private var font:Class;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			
			 //entry point
			 
			 var ldrContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain); 
			 
			fontloader = new Loader();
			fontloader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontsLoaded);
			fontloader.load(new URLRequest("ShagExpert.swf"), ldrContext);
		}	
		
		private function fontsLoaded(e:Event):void {			
			//fontloader.contentLoaderInfo.removeEventListener(Event.COMPLETE, fontsLoaded);
			//font = fontloader.contentLoaderInfo.applicationDomain.getDefinition("_ShagExpert") as Class;	
			//
			//Font.registerFont(font);		
			//
			startApp();
		}
		
		private function startApp():void 
		{			
			var myMc:MyMC = new MyMC();			
			//addChild(myMc);
			//myMc.tf.embedFonts = true;			
			//myMc.tf.text = "1) A Test Test Test\n2)A Test Test Test";
			
			var tf:TextField = new TextField();
			tf.selectable = false;
			addChild(tf);
			tf.x = tf.y = 50;
			
			trace(Font.enumerateFonts());
			var arrFont:Array = Font.enumerateFonts();
			var tfo:TextFormat = new TextFormat("ShagExpert-Lounge", 16, 0xcc0000);			
			
			tf.defaultTextFormat = tfo;
			tf.embedFonts = true;
			tf.text = "Hello World\n Test test Test";
			
		}
		
	}
	
}